package com.bignerdranch.android.geoquiz

import android.util.Log
import androidx.lifecycle.ViewModel

private const val TAG="QuizViewModel"
class QuizViewModel:ViewModel() {
    var currentIndex=0
    var cheatNumber=3
    var isCheater=false
    var score=0
    var mIsCheat: BooleanArray= booleanArrayOf(false,false,false,false,false,false)

    private var questionBank= listOf(
        Question(R.string.question_australia,true,false),
        Question(R.string.question_oceans,true,false),
        Question(R.string.question_mideast,false,false),
        Question(R.string.question_africa,false,false),
        Question(R.string.question_americas,true,false),
        Question(R.string.question_asia,true,false),
        Question(R.string.question_zhulei,true,false)

    )

    val currentQuestionAnswer:Boolean
      get() = questionBank[currentIndex].answer
    val currentQuestionText:Int
      get() = questionBank[currentIndex].textResId

    fun moveToNext()
    {
        currentIndex=(currentIndex+1)%questionBank.size
    }
    fun moveToPrev()
    {
        if (currentIndex>=1)
        {
            currentIndex=(currentIndex-1)%questionBank.size
        }
        else
        {
            currentIndex=questionBank.size-1
        }
    }
    fun answerQuestion(){
        questionBank[currentIndex].isanswered=true

    }
    fun winScore()
    {
       score=score+1
    }
    fun loseScore()
    {
        score=score-1
    }

    fun cheat()
    {
        cheatNumber--
    }

    val currentIsanswered:Boolean
    get()=questionBank[currentIndex].isanswered



}